package com.webserver.core;

import com.webserver.http.HttpServletRequest;

import java.io.IOException;
import java.net.Socket;

/**
 * Author：毕龙
 * Date: 2022/9/18 14:50
 *
 */
public class ClientHandler implements Runnable{
    private Socket socket;
    public ClientHandler(Socket socket){
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
//            1:解析请求(将客户端发送过来的请求内容读取到)
            HttpServletRequest request = new HttpServletRequest(socket);
//            2:处理请求(根据请求内容进行对应的处理)

//            3:发送响应(将处理结果回馈给浏览器)


        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //按照HTTP协议要求，处理最后要断开连接
            try {
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
